import { ExecutionContext, createParamDecorator } from '@nestjs/common'
import { USER_TOKEN_DATA } from '../contants/config.contants'

// @User()
export const User = createParamDecorator((data: string, ctx: ExecutionContext) => {
  const request = ctx.switchToHttp().getRequest()

  const user = request[USER_TOKEN_DATA]

  return data ? user?.data : user
})
